import cv2
import numpy as np

img1 = cv2.imread('3/lena_color.jpg')
img1 = cv2.resize(img1, (300, 300))
np.random.seed(42)
img2 = np.random.randint(0, 256, (300, 300, 3), dtype=np.uint8)
img = cv2.bitwise_xor(img1, img2)

cv2.imshow('img', img)
cv2.waitKey(0)
cv2.destroyAllWindows()
cv2.imwrite('5/5_2.jpeg', img)
cv2.imwrite('5/5_2.bmp', img)

img3 = cv2.imread('5/5_2.bmp')
img = cv2.bitwise_xor(img3, img2)
cv2.imshow('img', img)
cv2.waitKey(0)
cv2.destroyAllWindows()
img4 = cv2.imread('5/5_2.jpeg')
img = cv2.bitwise_xor(img4, img2)
cv2.imshow('img', img)
cv2.waitKey(0)
cv2.destroyAllWindows()